﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Web;

namespace DHQGHN.MVC.Security
{
    public class MyPrincipal : IPrincipal
    {
        public IIdentity Identity { get; private set; }

        public MyPrincipal(IIdentity identity)
        {
            this.Identity = identity;
        }

        public MyPrincipal(string userName)
        {
            this.Identity = new GenericIdentity(userName);
        }

        public bool IsInRole(string role)
        {
            if (Roles != null)
            {
                return Roles.Contains(role);
            }
            return false;
        }

        public List<string> Roles
        {
            get;
            set;
        }
    }
}